package com.quanxiaoha.weblog.web.service.impl;

import com.quanxiaoha.weblog.common.domain.dos.CommentDO;
import com.quanxiaoha.weblog.web.dao.CommentDao;
import com.quanxiaoha.weblog.web.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentDao commentDao;

    @Override
    public CommentDO addComment(CommentDO commentDO) {
        commentDao.insert(commentDO);
        return commentDO;
    }

    @Override
    public List<CommentDO> getCommentsByArticleId(Long articleId) {
        return commentDao.selectByArticleId(articleId);
    }

    @Override
    public Long getCommentCountByArticleId(Long articleId) {
        return commentDao.selectCountByArticleId(articleId);
    }
}